import { request } from '../request';

/**
 * 价格试算
 *
 * @param source 数据来源
 * @param date 计算日期
 * @param data 上传的数据
 */
export function fetchPriceCalc(params: { source: string; date: string; data?: any }) {
  return request<Api.PriceCalc.CalcResult>({
    url: '/api/price-calc/calc',
    method: 'post',
    data: params
  });
}

/**
 * 价格对比
 *
 * @param source 数据来源
 * @param date 对比日期
 * @param data 上传的数据
 */
export function fetchPriceCompare(params: { source: string; date: string; data?: any }) {
  return request<Api.PriceCalc.CompareResult[]>({
    url: '/api/compare/do',
    method: 'post',
    data: params
  });
}

/**
 * 导出对比结果
 *
 * @param data 表格数据
 */
export function fetchExportCompareResult(data: any[]) {
  return request<Blob>({
    url: '/api/compare/export',
    method: 'post',
    data: { data },
    responseType: 'blob' as any
  });
}
